<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="https://unpkg.com/react@16/umd/react.development.js"></script>
    <script src="https://unpkg.com/react-dom@16/umd/react-dom.development.js"></script>
    <script src="https://unpkg.com/babel-standalone@6.26.0/babel.js"></script>
</head>

<body>
    <div id="app"></div>

    <script type="text/babel">

        class MyDom extends React.Component {

            change = () => {
                // console.log(this.refs.strInput);
                console.log(this.refs.test.value);
            }
            change2 = () => {
                console.log(this.input1.value);
            }
            render() {
                return (
                    <div>
                        <input type="text" name="" id="" ref="test" />
                        <input type="text" name="" id="" ref={(c) => { this.input1 = c }} />

                        <button onClick={this.change}>按钮</button>
                        <button onClick={this.change2}>按钮2</button>
                    </div>
                )
            }
        }

        ReactDOM.render(<MyDom />, document.getElementById('app'))
        //字符串ref的效率不高
    </script>
</body>

</html>